package com.jzbooks.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.jzbooks.handler.MysqlMetaObjectHandler;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author mingPeng
 * @date 2021/4/18 13:36
 * @Description : mybatis-plus 配置类
 */
@Configuration
@MapperScan("com.jzbooks.mapper")
@EnableTransactionManagement
public class MyBatisPlusConfig {

    /**
     *  注册分页插件
     */
    @Bean
    public PaginationInterceptor paginationInterceptor(){
        return new PaginationInterceptor();
    }

    /**
     *     逻辑删除
     */
    @Bean
    public ISqlInjector sqlInjector(){
        return new LogicSqlInjector();
    }

    /**
     *   填充策略
     */
    @Bean
    public MetaObjectHandler metaObjectHandler(){
        return  new MysqlMetaObjectHandler();
    }

}
